/*
 * @Description: 我的车辆(信息)   MyVehicle
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-27 14:34:02
 * @LastEditors: zhengzhuang
 * @LastEditTime: 2020-08-01 14:37:08
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:C20Driver/provider/driver_information.dart';
import 'package:C20Driver/routers/navigator_util.dart';

class MyVehicle extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // DriverInformation provider = Provider.of<DriverInformation>(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('我的车辆'),
      ),
      body: Container(
        padding: EdgeInsets.all(ScreenUtil().setWidth(25.0)),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            _noVehicles(context),
          ],
        ),
      ),
    );
  }

  // 没有添加车辆
  Widget _noVehicles(context) {
    return Card(
      child: Container(
        width: ScreenUtil().setWidth(700.0),
        height: ScreenUtil().setWidth(680.0),
        child: Column(
          children: <Widget>[
            Image.asset(
              'assets/icon/myVehicleBgIcon.png',
              width: ScreenUtil().setWidth(400.0),
            ),
            Consumer<DriverInformation>(builder: (context, state, child) {
              return Text(
                state.driverInfo.brandModels != null
                    ? '${state.driverInfo.brandModels}(${state.driverInfo.vehicleColor})'
                    : '您当前还没有车辆信息',
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(34.0),
                  fontWeight: state.driverInfo != null
                      ? FontWeight.w700
                      : FontWeight.w100,
                  color: Colors.black,
                ),
              );
            }),
            SizedBox(height: ScreenUtil().setWidth(20.0)),
            Consumer<DriverInformation>(builder: (context, state, child) {
              return Text(
                state.driverInfo.vehicleNumberPlate != '' &&
                        state.driverInfo.vehicleNumberPlate != null
                    ? state.driverInfo.vehicleNumberPlate
                    : '',
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(32.0),
                  color: Colors.black54,
                ),
              );
            }),
            SizedBox(height: ScreenUtil().setWidth(50.0)),
            InkWell(
              child:
                  Consumer<DriverInformation>(builder: (context, state, child) {
                return Text(
                  state.driverInfo.brandModels != '' &&
                          state.driverInfo.brandModels != null
                      ? '前往补齐 >'
                      : '前往添加 >',
                  style: TextStyle(
                    fontSize: ScreenUtil().setSp(32.0),
                    color: Color.fromARGB(255, 255, 153, 0),
                  ),
                );
              }),
              onTap: () =>
                  NavigatorUtil.jump(context, '/newVehicleInformation'),
            ),
          ],
        ),
      ),
    );
  }
}
